//
//  HistoryTableView.m
//  BCW
//
//  Created by Mac on 16/3/30.
//  Copyright © 2016年 mac. All rights reserved.
//

#import "HistoryTableView.h"
#import "HistoryCell.h"
#import "HistoryTabelHeadView.h"
#import "HistoryModel.h"
#import "HistoryOneCellModel.h"
#import "LotteryCellModel.h"
#import "TableHeadView.h"


@interface HistoryTableView()<UITableViewDataSource, UITableViewDelegate>

@property (nonatomic, strong) HBWNetDataManager *manager;
@end

@implementation HistoryTableView
- (HBWNetDataManager *)manager
{
    if (!_manager) {
        _manager = [HBWNetDataManager shareSessionManager];
    }
    return _manager;
}

- (NSMutableArray *)historyArr
{
    if (!_historyArr) {
        _historyArr = [NSMutableArray array];
    }
    return _historyArr;
}

- (instancetype)initWithFrame:(CGRect)frame style:(UITableViewStyle)style{
    self = [super initWithFrame:frame style:style];
    if (self) {
        self.delegate = self;
        self.dataSource = self;
        self.separatorStyle = UITableViewCellSeparatorStyleNone;
        self.showsVerticalScrollIndicator = NO;
    }
    return self;
}


- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    static NSString *ID = @"cell";
    HistoryCell *cell = [tableView dequeueReusableCellWithIdentifier:ID];
    if (!cell) {
        cell = [[NSBundle mainBundle] loadNibNamed:@"HistoryCell" owner:nil options:nil].firstObject;
        if (indexPath.row == 0)
        {
            // 取出模型
            HistoryOneCellModel *model = self.historyArr[indexPath.row];
            cell.historyonecellmodel = model;
            
        }else
        {
            HistoryModel *model = self.historyArr[indexPath.row];
            cell.historylotterymodel = model;
            
        }

    }
    if (indexPath.row % 2 == 0) {
        cell.viewColor = WhiteColor;
    }
    else{
        cell.viewColor = [UIColor groupTableViewBackgroundColor];
    }
    return cell;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return self.historyArr.count;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return 35;
}

- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
    HistoryTabelHeadView *headtabel = [HistoryTabelHeadView historyheadviewFormXib];
    return headtabel;
}
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)sectio{
    return 35.f;
}



@end
